package com.walkerma.library;

import android.content.Context;
import android.media.AudioManager;

public class Sound {

	public static void setSoundMode(Context context, int ringerMode){
		//<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
		//<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
		//<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);
		if(am == null) return;
		am.setRingerMode(ringerMode); 
		//setRingerMode(ringerMode) AudioManager.RINGER_MODE_NORMAL RINGER_MODE_SILENT RINGER_MODE_VIBRATE
	}


	public static int getSoundMode(Context context){
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);
		if(am == null) return AudioManager.RINGER_MODE_NORMAL;
		return am.getRingerMode();
	}


	public static void setMaxInCallVolume(Context context){
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);
		am.setMode(AudioManager.MODE_IN_CALL);     
		am.setStreamVolume(AudioManager.STREAM_RING, 
				am.getStreamMaxVolume(AudioManager.STREAM_RING) - 1, 0); 
	}

	
	public static void setMaxSystemVolume(Context context){
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);   
		am.setStreamVolume(AudioManager.STREAM_SYSTEM, 
				am.getStreamMaxVolume(AudioManager.STREAM_SYSTEM) - 1, 0); 
	}

	
	public static void setMaxMusicVolume(Context context){
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);   
		am.setStreamVolume(AudioManager.STREAM_MUSIC, 
				am.getStreamMaxVolume(AudioManager.STREAM_MUSIC) - 1, 0); 
	}

	
	public static void setMaxNotificationVolume(Context context){
		AudioManager am = (AudioManager)context.
				getSystemService(Context.AUDIO_SERVICE);   
		am.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 
				am.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION) - 1, 0); 
	}	

}
